#include "FaceUV.h"

#include <sstream>

// TODO: remove after debugging
#include <OgreLogManager.h>
#define LOG(M) Ogre::LogManager::getSingleton().logMessage(M)
///////////////////////////////

namespace MHX
{
	bool FaceUV::parse(const TokenLine &tokens)
	{
		int index = 0;

		for(TokenIterator i = tokens.begin() + 1; i != tokens.end(), index < 8; i++, index++)
		{
			std::stringstream s(*i);
			s >> uv[index];
			if(s.fail())
			{
				if(index < 5)
					return false;
				break;
			}
		}

		nUV = (index == 8) ? 4 : 3;
		return true;
	}

	float &FaceUV::operator[](int i)
	{
		return uv[i];
	}

	const float &FaceUV::operator[](int i) const
	{
		return uv[i];
	}
}